package com.example.zsf.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.zsf.R;
import com.example.zsf.activity.mobile.MobileDetailActivity;
import com.example.zsf.model.FavoriteModel;
import com.example.zsf.utils.DebouncedOnClickListener;

import java.util.List;

public class FavoriteListAdapter extends BaseQuickAdapter<FavoriteModel.FavoriteListModel, BaseViewHolder> {
    private Context context;

    public FavoriteListAdapter(Context context,int layoutResId, List<FavoriteModel.FavoriteListModel> data) {
        super(layoutResId, data);
        this.context = context;
    }


    @Override
    protected void convert(BaseViewHolder baseViewHolder, FavoriteModel.FavoriteListModel favoriteListModel) {
        Glide.with(context).load(favoriteListModel.getAds_img()).into((ImageView) baseViewHolder.getView(R.id.content_im));
        baseViewHolder.setText(R.id.textView22,favoriteListModel.getAds_name());

        baseViewHolder.setText(R.id.textView30,favoriteListModel.getAds_ip());
        baseViewHolder.setText(R.id.textView31,favoriteListModel.getAds_xl());
        baseViewHolder.setText(R.id.textView32,favoriteListModel.getAds_qq());

        baseViewHolder.setText(R.id.textView33,favoriteListModel.getAds_js());

        baseViewHolder.getView(R.id.info_bt).setOnClickListener(new DebouncedOnClickListener(400) {
            @Override
            public void onDebouncedClick(View v) {
                Intent intent = new Intent(context, MobileDetailActivity.class);
                intent.putExtra("id",favoriteListModel.getAds_id());
                intent.putExtra("image_url",favoriteListModel.getAds_img());
                context.startActivity(intent);
            }
        });
    }
}
